package com.yoga.manager.beanUtil;

import com.yoga.common.bo.PrivateVipBO;
import com.yoga.dao.domain.PrivateVipDO;
import org.springframework.util.CollectionUtils;

import java.util.ArrayList;
import java.util.List;

/**
 * 类PrivateVipBeanUtil.java的实现描述：工具类
 * 
 * @Author hdx
 * @Date 2020年09月24日
 */
public class PrivateVipBeanUtil {

    private PrivateVipBeanUtil(){
    }

    public static PrivateVipDO privateVipBOToDO(PrivateVipBO srcObj) {
        if (srcObj == null) {
            return null;
        }
        PrivateVipDO targetObj = new PrivateVipDO();
        targetObj.setId(srcObj.getPrivateVipId());//id
        targetObj.setYogaUserId(srcObj.getYogaUserId());//用户id
        targetObj.setVipType(srcObj.getVipType());//会员状态：0、非会员，1、私教会员
        targetObj.setClassNum(srcObj.getClassNum());//课程数量
        targetObj.setAboutNum(srcObj.getAboutNum());//已约次数
        targetObj.setVipPrice(srcObj.getVipPrice());//vip价格
        targetObj.setTotalPrice(srcObj.getTotalPrice());//累计消费金额
        targetObj.setDeleteMark(srcObj.getDeleteMark());//0、正常，1、删除
        targetObj.setCreateTime(srcObj.getCreateTime());
        targetObj.setUpdateTime(srcObj.getUpdateTime());
        return targetObj;
    }

    public static PrivateVipBO privateVipDOToBO(PrivateVipDO srcObj) {
        if (srcObj == null) {
            return null;
        }
        PrivateVipBO targetObj = new PrivateVipBO();
        targetObj.setPrivateVipId(srcObj.getId());//id
        targetObj.setYogaUserId(srcObj.getYogaUserId());//用户id
        targetObj.setVipType(srcObj.getVipType());//会员状态：0、非会员，1、私教会员
        targetObj.setClassNum(srcObj.getClassNum());//课程数量
        targetObj.setAboutNum(srcObj.getAboutNum());//已约次数
        targetObj.setVipPrice(srcObj.getVipPrice());//vip价格
        targetObj.setTotalPrice(srcObj.getTotalPrice());//累计消费金额
        targetObj.setDeleteMark(srcObj.getDeleteMark());//0、正常，1、删除
        targetObj.setCreateTime(srcObj.getCreateTime());
        targetObj.setUpdateTime(srcObj.getUpdateTime());
        return targetObj;
    }

    public static List<PrivateVipBO> doList2BOList(List<PrivateVipDO> doList) {
        List<PrivateVipBO> boList = new ArrayList<>();
        if (CollectionUtils.isEmpty(doList)) {
            return boList;
        }
        doList.stream().forEach(privateVipDO -> boList.add(PrivateVipBeanUtil.privateVipDOToBO(privateVipDO)));
        return boList;
    }
}